import re
content = '''
<html>
<head><title>表格</title></head>
<body>
    <table  border=1>
        <tr><th>学号</th><th>姓名</th></tr>
        <tr><td>1001</td><td>杨秀璋</td></tr>
        <tr><td>1002</td><td>严娜</td></tr>
    </table>
</body>
</html>
'''
res = r'<tr>(.*?)</tr>'								#获取<tr></tr>间内容
texts = re.findall(res, content, re.S|re.M)
for m in texts:
    print(m)
for m in texts:										#获取<th></th>间内容#获取<th></th>间内容
    res_th = r'<th>(.*?)</th>'
    m_th = re.findall(res_th, m, re.S|re.M)
    for t in m_th:
        print(t)
res = r'<td>(.*?)</td><td>(.*?)</td>'				#直接获取<td></td>间内容
texts = re.findall(res, content, re.S|re.M)
for m in texts:
    print(m[0],m[1])
